<template>
  <div class="wrapper" ref="wrapper">
    <div class="content" > 
      <slot></slot>
    </div>
  </div>
</template>

<script>
    import BScroll from 'better-scroll'

    export default {
        name: "Scroll",
        props:{
            probeType :0,
            pullUpLoad:{
                type: Boolean,
                default() {
                    return true;
                }
            }
        },
        data(){
            return {
              scroll:{
                  type:Object,
                  default(){
                      return {}
                  }
              },
              message:"我是小希"
            }
        },
        mounted(){
            this.scroll = new BScroll(this.$refs.wrapper,{
              click:true,
              probeType:this.probeType,
              pullUpLoad:this.pullUpLoad,
            })
            this.scroll.on("scroll",(position)=>{
                this.$emit('scrollPosition',position)
            })
            this.scroll.on("pullingUp",()=>{
                this.$emit('getMore')
            })
        },
        methods:{
            scrollTo(x,y,time=300){
                this.scroll && this.scroll.scrollTo(x,y,time)
            },
            finishPullUp(){
                this.scroll.finishPullUp()
            },
            refresh(){
                this.scroll && this.scroll.refresh()
            }

        }
    }
</script>

<style scoped>

</style>
